var kthSmallest = function (root, k) {
    let arr = []
    function middle(root) {
        if (root === null) return;
        middle(root.left)
        arr.push(root.val)
        middle(root.right)
    }
    middle(root)
    return arr[k - 1]
};


